/**
 * @Description : mongodb数据库连接
 */
const mongoose = require('mongoose');

const connect = () => {
    mongoose.set('strictQuery', true); // 消除严格模式
    mongoose.connect(process.env.DATABASE_URL);
    const conn = mongoose.connection;
    conn.on('open', () => {
        console.log(`* DB Connection: OK\n************************\n`);
    });
    conn.on('error', (err) => {
        console.log(`* DB connecting Error: ${err}\n************************\n`);
        return;
    });
};

connect();

module.exports = { mongoose };
